{php include wl_template('common/header');}
{if empty($_GPC['lct'])}
<ul class="nav nav-tabs" id="myTab">
	<li class="active"><a href="javascript:;">应用信息</a></li>
</ul>
{/if}
<div class="app-content">
	<div class="app-filter">
		<div class="filter-action" style="padding-top:10px;">
			<a href="javascript:;" class="btn btn-primary js-pass" >还原应用信息</a>
		</div>
		<div class="filter-list">
			<form action="./index.php?" class="form-horizontal form-filter" id="form1">
				{php echo tpl_form_filter_hidden('cloud/plugin/index');}
				<input type="hidden" name="type" value="{$type}"/>
				<input type="hidden" name="lct" value="{$_GPC['lct']}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label">类型</label>
					<div class="col-sm-9">
						<div class="btn-group">
							<a href="{php echo ifilter_url('type:');}" class="btn {if $type == ''}btn-primary{else}btn-default{/if}">不限</a>
							{loop $types $key $row}
								<a href="{php echo ifilter_url('type:' . $key);}" class="btn {if $type == $key}btn-primary{else}btn-default{/if}">{$row['name']}</a>
							{/loop}
						</div>
					</div>
				</div>
				<div class="form-group form-inline">
					<label class="col-sm-2 control-label">关键字</label>
					<div class="col-sm-9">
						<input class="form-control" name="keyword" placeholder="插件名称/插件标识" type="text" value="{$_GPC['keyword']}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"></label>
					<div class="col-sm-9">
						<button class="btn btn-primary">筛选</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="app-table-list">
		<form action="" class="form-table form form-validate" method="post">
			{if empty($plugins)}
			<div class="no-result">
				<p>还没有相关数据</p>
			</div>
			{else}
			<div class="table-responsive js-table">
				<table class="table table-hover">
					<thead>
					<tr>
						<th>开关</th>
						<th>图标</th>
						<th>标识</th>
						<th>插件名称</th>
						<th>插件简介</th>
						<th>排序</th>
					</tr>
					</thead>
					{loop $plugins $plugin}
					<tr>
						<input type="hidden" name="ids[]" value="{$plugin['id']}">
						<td>
							<div class="checkbox checkbox-inline">
								<input type="checkbox" name="statuss[]" value="{$plugin['id']}" {if $plugin['status'] == 1}checked{/if}>
								<label></label>
							</div>
						</td>
						<td>
							<div class="js-selectAttachment img-item" style="width: 50px; height: 50px; background: #1ab394;">
								<img src="{php echo tomedia($plugin['thumb']);}" width="50" height="50"/>
								<input type="hidden" name="pluginimgs[]">
							</div>
						</td>
						<td>{$plugin['name']}</td>
						<td>
							<input type="text" name="titles[]" value="{$plugin['title']}" class="form-control with200"/>
						</td>
						<td>
							<input type="text" name="abilitys[]" value="{$plugin['ability']}" class="form-control"/>
						</td>
						<td>
							<input type="text" name="displayorders[]" value="{$plugin['displayorder']}" class="form-control with100"/>
						</td>
					</tr>
					{/loop}
				</table>
				<div class="app-table-foot clearfix">
					<div class="pull-left">
						<input name="token" type="hidden" value="{$_W['token']}" />
						<input type="submit" class="btn btn-primary" name="submit" value="提交修改" />
					</div>
				</div>
			</div>
			{/if}
		</form>
	</div>
</div>
<script language="javascript">
    $(function(){
        require(['jquery', 'util'], function ($, util) {
			$('.js-selectImg').unbind('click').click(function () {
				var imgitem = $(this).closest('.img-item');
				util.image('', function (data) {
					imgitem.find('img').attr('src', data['url']);
					imgitem.find('input').val(data['attachment']);
				});
			});
		});
    });

	$('.js-pass').click(function(e){
		e.stopPropagation();
		var id = $(this).attr('order-id');
		util.nailConfirm(this, function(state) {
			if (!state) return;
			$.post("{php echo web_url('cloud/plugin/return_plugin')}", {}, function(data) {
				if(!data.errno){
					util.tips('还原成功');
					location.reload();
				}else{
					util.tips('还原失败');
				};
			}, 'json');
		}, {html:'确认还原所有应用信息吗？', placement:'right'});
	});

</script>
{php include wl_template('common/footer');}